#coding:utf-8
from lovewith.settings import DEBUG, SITE_URL
from lovewith.api.qq_tools import QQ
from lovewith.api.weibo_tools import Weibo
from lovewith.website.views.modules.link import LinkApi
from lovewith.website.views.modules.color import ColorApi
from lovewith.website.views.modules.site import WebSiteApi
from lovewith.website.views.modules.category import CategoryApi
from lovewith.subscribe.views.modules.subscribe import SubscribeApi


def site_info(request):
    weibo_auth_uri = Weibo().get_login_server()
    qq_auth_uri = QQ().get_login_server()
    is_admin = False
    is_login = False
    sub_keywords = None

    if request.user.is_authenticated():
        is_login = True
        #订阅过的关键词
        sub_keywords = SubscribeApi.get_by_uid(request.user.id)
        if request.user.is_staff:
            is_admin = True

    return {
        'domain': SITE_URL,
        'debug': DEBUG,
        'is_login': is_login,
        'is_admin': is_admin,
        'sub_keywords': sub_keywords,
        'weibo_auth_uri': weibo_auth_uri,
        'qq_auth_uri': qq_auth_uri,
        'site_options': WebSiteApi.get_all(),
        'links': LinkApi.get_recommand()
    }
